package cn.edu.fudan.bdke.ncov.web.controller;

import cn.edu.fudan.bdke.ncov.data.epidemic.HuBeiEpidemicSituation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author xym
 * @since 2020/2/13
 */
@RestController
@RequestMapping("/data")
public class DataCollectionController {

    @GetMapping(value = "/parse/total")
    public Map<String, Object> parseData(@RequestParam(value = "stanfordNlpToolkit/segmenter/data") String rawString) {
        HuBeiEpidemicSituation huBeiEpidemicSituation = HuBeiEpidemicSituation.getInstance();
        huBeiEpidemicSituation.collectData(rawString);
        Map<String, Object> result = new HashMap<>();
        result.put("date", huBeiEpidemicSituation.getDate());
        result.put("total", huBeiEpidemicSituation.getTotalEpidemic());
        result.put("sub", huBeiEpidemicSituation.getCityEpidemicMap());
        return result;
    }
}
